package com.jiaai.web.zfp_back.gift;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.exception.ServerException;
import com.jiaai.gift.api.ICarApi;
import com.jiaai.gift.model.CarVO;

import com.jiaai.util.RestResultGenerator;
import org.springframework.web.bind.annotation.*;

/**
 * class_name:ZBCarController
 * describe:TODO
 * create_user:张昉平
 * create_date:2017/12/27
 * create_date:16:04
 */
@RestController
@RequestMapping("/api/v1/admin/car")
public class ZBCarController {

    @Reference
    private ICarApi iCarApi;

    @RequestMapping("/list")
    public Object list(@RequestParam Integer curr, Integer typeId)throws ServerException {
        return  RestResultGenerator.genSuccessResult(iCarApi.getAll(curr, typeId));
    }

    @PostMapping("/saveoredit")
    public Object saveOrEdit(@RequestBody CarVO carVO)throws ServerException {
        iCarApi.saveOrEdit(carVO);
        return  RestResultGenerator.genSuccessResult("操作成功");
    }

    @RequestMapping("/delete/{id}/{flag}")
    public Object delete(@PathVariable("id") Integer id, @PathVariable("flag") Integer flag)throws ServerException {
        iCarApi.delete(id, flag);
        return  RestResultGenerator.genSuccessResult("操作成功");
    }

    @GetMapping("/xlk")
    public Object xlk(){
        return RestResultGenerator.genSuccessResult(iCarApi.xlk());
    }


}
